const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const Time = require('../public/javascripts/time')

const BookSchema = new Schema({
    bookname: {     //书名
        type: String,
        required: true
    },
    sort: {         //分类
        type: Array,
        required: true
    },
    writername: {       //作者名
        type: String,
    },
    writerid: {     //作者id
        type:String
    },
    state: {    //书籍状态
        type: Number,
        default: 2
    },
    isend: {    //连载完结状态（是否完结？默认false
        type: Number,
        default:0
    },
    size: {     //书籍字数
        type: Number,
        default: 0
    },
    avatar: {       //头像
        type: String,
        default: 'http://127.0.0.1:3000/uploads/book/moren.png'
    },
    explain:{       //简介
        type: String,
        required: true
    },
    thelast:{    //最后一章
        type: String,
        default:''
    },
    hei: {      //黑名单
        type:Array
    },
    thiscollection: {   //收藏数
        type: Number,
        default: 0
    },
    date: {         //创建日期
        type: String,
        default: new Time().getTime()
    },
})

module.exports = Book = mongoose.model("books", BookSchema);